<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>   
<c:set var="base" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>日常管理</title>
  <link href="${base}/assets/css/public.css" rel="stylesheet">
  <script src="${base}/assets/js/jquery.min.js"></script>
  <link rel="stylesheet" type="text/css" href="${base}/assets/css/jquery.searchableSelect.css" /> 
  <script type="text/javascript" src="${base}/assets/js/jquery.searchableSelect.js"></script> 
</head>
<body>

<div class="top">
   <script type="text/javascript">
   		<c:import url="../commons/top.jsp"/>
   </script>
</div>
<div class="wrap">
  <div class="side">
   <c:import url="../commons/sidebar.jsp"/>
  </div>
  <div class="cont">
    <div class="bread">
      <span>日常管理</span><span>&nbsp;&gt;&nbsp;</span><span>出入库管理</span>
      <div class="clear"></div>
    </div>
    <div  style=" withd:100%;text-align:center;">
      <p style="font-size: 15px;font-weight:bold;color:#100cf5;">当前位置：${whname}</p>
    </div>
    <div class="icon">
      <div class="icon-item">
        <img src="${base}/assets/img/ck.png" alt="" id="outimg"/>
        <p>出库</p>
      </div>
      <div class="icon-item">
        <img src="${base}/assets/img/rk.png" alt="" id="inimg"/>
        <p>入库</p>
      </div>
      <div class="icon-item">
        <img src="${base}/assets/img/cx.png" alt="" id="searchimg"/>
        <p>查询</p>
      </div>
      <div class="clear"></div>
    </div>
	<div class="portlet-body" id="outStock">
         <div class="tabbable tabbable-tabdrop" style="text-align:center;"> 
         	<input id="outinput" style="width:50%;height:27px" placeholder="扫描出库"/>   
         </div>
         <br/>
         <table style="width:100%"  id="outinputtable">
          <thead>
             <tr style="background-color:#ccc;">
             	<th>所属类别</th>
             	<th>功能类别</th>
                 <th>设备类别</th>
                 <th>品       牌 </th> 
                 <th>旧  编 号 </th>
                 <th>编       号</th>
                 <th>型       号</th>
                 <th>出厂编号</th>
                 <th>投产年月</th>
                 <th>折旧年限</th>
                 <th>采购价格（元）</th> 
                 <th>当前位置</th>
                 <th>状       态</th>
                 <th>备       注</th>
             </tr>
           </thead>
           <tbody>
           </tbody>
        </table>
         <div  style=" withd:100%;text-align:center;">
             <a style="background: #4876FF" onclick="submitoutlist()">提交</a>
             <a style="background: #ff76FF" onclick="submitoutrest()">重置</a>
         </div>
         <script type="text/javascript">
               function submitoutlist(){
					var mymessage=window.confirm('请确认无误后！点击确定提交');  
   					if(mymessage==true){  
	 	   				$.ajax({
	 	       				type: "POST",
	 	       				url: '${base}/back/submitinstock.do?para=2',
	 	       				dataType: "json", // 数据格式:JSON
	 	       				success: function (data) {
		 	    	   			if(data.ok == 'fal'){
		 	    		  			alert("操作失败！！！！"); 
		 	    	   			}else if(data.ok == 'ok'){
		 	    		  			alert("出库成功！！！！");
		 	    		  			$("#outinputtable tbody").html("");
		 	    		  			$('#outinput').focus();
		 	    	   			}   
	 	       				}
	 	   				});
   					}else if(mymessage==false){  
   	 					return; 
   					} 
              }
              function submitoutrest(){
              	var mymessage=window.confirm('重置后将取消全部扫码记录！！');  
   				if(mymessage==true){  
	 	   			$.ajax({
	 	       			type: "POST",
	 	       			url: '${base}/back/submitoutrest.do',
	 	       			dataType: "json", // 数据格式:JSON
	 	       			success: function (data) {
		 	    	   		if(data.ok == 'fal'){
		 	    		  		alert("重置失败！！！！"); 
		 	    	   		}else if(data.ok == 'ok'){
		 	    		  		alert("重置成功！！！！");
		 	    		  		$("#outinputtable tbody").html("");
		 	    		  		$('#outinput').focus();
		 	    	   		}   
	 	       			}
	 	   			});
				 }else if(mymessage==false){  
				   	 return; 
				 } 
              }
		</script> 
	</div>
	
	<div class="portlet-body" id="inStock">
        <div class="tabbable tabbable-tabdrop" style="text-align:center;"> 
        	<input id="ininput" style="width:50%;height:27px" placeholder="扫描入库"/>   
        </div>
        <br/>
           <table style="width:100%"id="ininputtable">
               <thead>
               <tr style="background-color:#ccc;">
               	<th>所属类别</th>
               	<th>功能类别</th>
                   <th>设备类别</th>
                   <th>品       牌 </th> 
                   <th>旧  编 号 </th>
                   <th>编       号</th>
                   <th>型       号</th>
                   <th>出厂编号</th>
                   <th>投产年月</th>
                   <th>折旧年限</th>
                   <th>采购价格（元）</th> 
                   <th>当前位置</th>
                   <th>状       态</th>
                   <th>备       注</th>
               </tr>
               </thead>
               <tbody>
               </tbody>
           </table>        
            <div style=" withd:100%;text-align:center;">
                <a style="background: #4876FF" onclick="submitinputlist()" >提交</a>
                <a style="background: #ff76FF" onclick="submitinputrest()">重置</a>
            </div>
            <script type="text/javascript">
            	function submitinputlist(){
					var mymessage=window.confirm('请确认无误后！点击确定提交');  
					if(mymessage==true){  
						$.ajax({
							type: "POST",
							url: '${base}/back/submitinstock.do?para=1',
							dataType: "json", // 数据格式:JSON
							success: function (data) {
						 		if(data.ok == 'fal'){
						 	    	alert("操作失败！！！！"); 
						 		}else if(data.ok == 'ok'){
						 	    	alert("入库成功！！！！");
						 	    	$("#ininputtable tbody").html("");
						 	    	$('#ininput').focus();
						 		}
						 	    	   
						 	          
							}
						});
					}else if(mymessage==false){  
					 	return; 
					} 
           		}
            	function submitinputrest(){
                	var mymessage=window.confirm('重置后将取消全部扫码记录！！');  
 					if(mymessage==true){  
 						$.ajax({
							type: "POST",
						 	url: '${base}/back/submitinputrest.do',
							dataType: "json", // 数据格式:JSON
							success: function (data) {
						 		if(data.ok == 'fal'){
						 	    	alert("重置失败！！！！"); 
						 		}else if(data.ok == 'ok'){
						 			alert("重置成功！！！！");
						 	    	$("#ininputtable tbody").html("");
						 	    	$('#ininput').focus();
						 	    }
							 }
						});
 					}else if(mymessage==false){  
 					 	return; 
 					} 
            	}
	 	</script>
	</div>
	
	
	<div class="portlet-body" id="inoutsearch">
        <div class="tabbable tabbable-tabdrop" style="text-align:center;"> 
        	<input id="searchinput" style="width:50%;height:27px" placeholder="输入设备号查询（回车查询）"/>   
        </div>
         <br/>
         <table style="width:100%" id="searchinputtable">
             <thead>
             <tr style="background-color:#ccc;">
             	<th>设备编号</th>
                 <th>操作类型</th> 
                 <th>原位置 </th>
                 <th>所在位置</th>
                 <th>操作用户</th>
                 <th>操作时间</th>
             </tr>
             </thead>
             <tbody>
             </tbody>
         </table> 
     </div>
  </div>
  <div class="clear"></div>
</div>
</body>
<script type="text/javascript">
$(function(){
	$('#outStock').hide();
	$('#inStock').hide();
	$('#inoutsearch').hide();
	
	$("#outimg").click(function(){
		
		$('#outStock').show();
		$('#inStock').hide();
		$('#inoutsearch').hide();
		$('#outinput').focus();
		$("#outimg").attr('src','${base}/assets/img/ckg.png');
		$("#inimg").attr('src','${base}/assets/img/rk.png');
		$("#searchimg").attr('src','${base}/assets/img/cx.png');
	  });
	$("#inimg").click(function(){

		$('#outStock').hide();
		$('#inStock').show();
		$('#inoutsearch').hide();
		$('#ininput').focus();
		$("#outimg").attr('src','${base}/assets/img/ck.png');
		$("#inimg").attr('src','${base}/assets/img/rkg.png');
		$("#searchimg").attr('src','${base}/assets/img/cx.png');
	  });
	$("#searchimg").click(function(){

		$('#outStock').hide();
		$('#inStock').hide();
		$('#inoutsearch').show();
		$('#searchinput').focus();
		$("#outimg").attr('src','${base}/assets/img/ck.png');
		$("#inimg").attr('src','${base}/assets/img/rk.png');
		$("#searchimg").attr('src','${base}/assets/img/cxg.png');
	  }); 
  $('#ininput').keypress(function (event) {
        if (13 == event.keyCode) {

        	var para = $("#ininput").val();
        	$.ajax({
                type: "POST",
                dataType: "json", // 数据格式:JSON
                url: '${base}/back/instock.do?para='+para,
                success: function (data) {
             	   if(data.ok == 'ok'){
	             		 if(data.ddvo !=null){
	             			addtable("ininputtable",data.ddvo,data.iost)
	             		 }
	             		$("#ininput").val("");
             	   }else if(data.ok =='yck'){
             		  alert("设备已入库！");
             		  $("#ininput").val("");
             		  $('#ininput').focus();
             	   }else if(data.ok =='ybf'){
             		  alert("设备已报废！");
             		  $("#ininput").val("");
             		  $('#ininput').focus();
             	   }else if(data.ok =='sck'){
             		  alert("扫码失败！");
             		  $("#ininput").val("");
             		  $('#ininput').focus();
             	   }else if(data.ok=="ysm"){
             		  alert("已扫码！");
             		  $("#ininput").val("");
             		  $('#ininput').focus();
             	   }else if(data.ok=="qtc"){
             		  alert("其他部门的设备，不能操作！");
             		  $("#ininput").val("");
             		  $('#ininput').focus(); 
             	   }else if(data.ok=="qtcyrk"){
             		  alert("其他部门的设备，请先出库后，再操作！！！");
             		  $("#ininput").val("");
             		  $('#ininput').focus(); 
             		  
             	   }else if(data.ok=="qtcybf"){
             		  alert("其他部门的设备已报废，不能操作！");
             		  $("#ininput").val("");
             		  $('#ininput').focus(); 
             	   }else if(data.ok=="qtcyck"){
             		  var mymessage=window.confirm('其他部门的已出库设备，是否转入！！！！');  
             		    if(mymessage==true){  
             		    	$.ajax({
             	                type: "POST",
             	                dataType: "json", // 数据格式:JSON
             	                url: '${base}/back/otherinstock.do?para='+data.para,
             	                success: function (data) {
             	                	if(data.ok == 'ok'){
             		             		 if(data.ddvo !=null){
             		             			addtable("ininputtable",data.ddvo,data.iost)
             		             		 }
             		             		$("#ininput").val("");
             	             	   		}
             	                	}
             	                })

             		    }else if(mymessage==false){ 
             		    	$("#ininput").val("");
                   		  	$('#ininput').focus(); 
             		    	 return; 
             		    }
             		  
             	   }
             	   
                }
            });
        }
    });
  $('#outinput').keypress(function (event) {
      if (13 == event.keyCode) {
      
      	var para = $("#outinput").val();
      	$.ajax({
              type: "POST",
              dataType: "json", // 数据格式:JSON
              url: '${base}/back/outstock.do?para='+para,
              success: function (data) {
           	   if(data.ok == 'ok'){

	             		 if(data.ddvo !=null){
	             			addtable("outinputtable",data.ddvo,data.iost)
	             		 }
	             		$("#outinput").val("");
	             		$('#ininput').focus(); 
           	   }else if(data.ok =='yck'){
           		  alert("设备已出库！");
           		  $("#outinput").val("");
           		  $('#outinput').focus();
           	   }else if(data.ok =='ybf'){
           		  alert("设备已报废！");
           		  $("#outinput").val("");
           		  $('#outinput').focus();
           	   }else if(data.ok =='sck'){
           		  alert("扫码失败！");
           		  $("#outinput").val("");
           		  $('#outinput').focus();
           	   }else if(data.ok=="ysm"){
          		  alert("已扫码！");
          		 $("#outinput").val("");
         		  $('#outinput').focus();
         	   }else if(data.ok=="qtc"){
          		  alert("不能操作其他部门设备！");
         		  $("#ininput").val("");
         		  $('#ininput').focus(); 
         	   }
              }
          });
      }
  });
  $('#searchinput').keypress(function (event) {
      if (13 == event.keyCode) {

      	var para = $("#searchinput").val();
      	$.ajax({
              type: "POST",
              dataType: "json", // 数据格式:JSON
              url: '${base}/back/searchios.do?para='+para,
              success: function (data) {
           		 if(data.ddvo !=null){
           			if(data.ddvo.length<=0){
              			 $("#searchinput").val("未找到相应的记录！！");
              		}else{
	           			$("#searchinputtable tbody").html("");
	           			$.each(data.ddvo,function(i,result){
	           				var str = "";
	           				if(result.corm =='1'){
	           					str = "新增";
	           				}else if(result.corm =='2'){
	           					str = "入库";
	           				}else if(result.corm =='3'){
	           					str = "出库";
	           				}else if(result.corm =='4'){
	           					str = "报废";
	           				}else if(result.corm =='5'){
	           					str = "修改";
	           				}
	           				var str2="";
	           				if(result.orwhname==null || result.orwhname==''){
	           					str2 = "无";
	           				}else{
	           					str2 =result.orwhname;
	           				}
	           					
	           				var tem = '<tr style="background-color:rgba(226, 223, 223);">'+
	              		 
	           					'<td>'+result.dno+'</td>'+
	              		  		'<td>'+str+'</td>'+
	              		  		'<td>'+str2+'</td>'+
	              		  		'<td>'+result.whname+'</td>'+
	              		  		'<td>'+result.couser+'</td>'+
	              		  		'<td>'+(result.cotime).substring(0,10)+'</td>'+
	          				'</tr>';
	          				
	          		    	$("#searchinputtable tbody").append(tem);
	           			});
              		}
           		 }else{
           			 $("#searchinput").val("请输入设备编号！！");
           		 }
           		 
              }
          });
      }
  });
	function addtable(id, ddvo,iost){
		var str = "";

		if(ddvo.status =='1'){
			str = "正常";
		}else if(ddvo.status =='2'){
			str = "已出库";
		}else if(ddvo.status =='3'){
			str = "已报废";
		}
		var tem = '<tr style="background-color:rgba(226, 223, 223);">'+
        		  '<td>'+ddvo.ccname+'</td>'+
        		  '<td>'+ddvo.cfname+'</td>'+
        		  '<td>'+ddvo.cdname+'</td>'+
        		  '<td>'+ddvo.brand+'</td>'+
        		  '<td>'+ddvo.oldno+'</td>'+
        		  '<td>'+ddvo.no+'</td>'+
        		  '<td>'+ddvo.xhno+'</td>'+
        		  '<td>'+ddvo.ccno+'</td>'+
        		  '<td>'+(ddvo.tcrq).substring(0,10)+'</td>'+
        		  '<td>'+ddvo.zjnx +'年'+'</td>'+
        		  '<td>'+ddvo.cgjg+'</td>'+
        		  '<td>'+ddvo.whname+'</td>'+
        		  '<td>'+str+'</td>'+
        		  '<td><a href="#" title=" '+ddvo.remark +'">'+ (ddvo.remark).substring(0,5)+'...'+'</a></td>'+
			       /* '<td><a href="${base}/back/devicdetail.do?id=" '+ddvo.id +'class="btn btn-outline  btn-sm purple ajaxify"><i class="fa fa-edit"></i>详情</a>'+  
			           '<a href="javascript:;"  onclick="deleteSingle(" ' +iost +' ");"> <i class="fa fa-trash-o"></i> 删除 </a>'+
			        '</td>' +  */
    			'</tr>';
    		$("#"+id+" tbody").append(tem);
	}
	function submitinputlist(){
		var mymessage=window.confirm('请确认无误后！点击确定提交');  
	    if(mymessage==true){  
	    	
	    }else if(mymessage==false){  
	    	 return; 
	    } 
	}
});
</script>
</html>